package com.gmall.rabbitmq.producer.controller;

import com.gmall.rabbitmq.config.FanoutExchange_Queue_Config;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/fanoutEx")
public class FanoutExController {

    @Autowired
    RabbitTemplate rabbitTemplate;


    @GetMapping("/produce/{routingKey}")
    public String produce(@PathVariable String routingKey){
        /**
         * String exchange 交换机
         * String routingKey 路由键
         * Object object 消息内容
         */
        rabbitTemplate.convertAndSend(
                FanoutExchange_Queue_Config.FANOUT_EXCHANGE,
                routingKey
                ,"hello,world");
        return "success";
    }


}
